<template>
  <div class="news-section">
    <h2 class="section-title">历史行程</h2>
    <div class="news-container">
      <el-timeline>
        <el-timeline-item
            v-for="news in deepList"
            :key="news.id"
            :timestamp="news.deedsTime"
            placement="top"
            class="timeline-item"
        >
          <el-card shadow="hover" class="news-card">
            <h3 class="news-title">{{ news.content }}</h3>
            <p class="news-effect">{{ news.effect }}</p>
          </el-card>
        </el-timeline-item>
      </el-timeline>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'
import { selectDeeps } from "@/api/deeps/index.js";
import { onMounted, ref } from "vue";

const router = useRouter()
const deepList = ref([])
const error = ref(null)

async function getDeeps() {
  error.value = null
  try {
    const res = await selectDeeps()
    deepList.value = res.data.rows || []
  } catch (err) {
    error.value = err.message || '获取事迹列表失败'
    console.error('获取事迹列表失败:', err)
  }
}

onMounted(() => {
  getDeeps()
})
</script>

<style scoped>
.news-section {
  padding: 50px 0;
  max-width: 1000px;
  margin: 0 auto;
}

.section-title {
  text-align: center;
  font-size: 26px;
  font-weight: 500;
  margin-bottom: 30px;
  color: #222;
  letter-spacing: 1px;
}

.news-container {
  padding: 0 15px;
}

.timeline-item ::v-deep(.el-timeline-item__node) {
  background-color: #4f6ef7;
  border: none;
}

.timeline-item ::v-deep(.el-timeline-item__tail) {
  border-left: 2px solid #e5e7eb;
}

.news-card {
  border-radius: 10px;
  transition: all 0.3s ease;
  border: 1px solid #f0f0f0;
}

.news-card:hover {
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
}

.news-title {
  margin-bottom: 8px;
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.news-effect {
  color: #666;
  font-size: 14px;
  line-height: 1.6;
}
</style>
